package com.manor.common.dialog

import android.content.Context
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BasePopupView
import com.lxj.xpopup.enums.PopupAnimation
import com.lxj.xpopup.impl.FullScreenPopupView
import com.lxj.xpopup.interfaces.SimpleCallback
import com.manor.common.R
import kotlinx.android.synthetic.main.dialog_complete_ad.view.*

/**
 * 完成任务
 * @constructor
 */
class AdTaskPopup(context: Context, var url :String) : FullScreenPopupView(context) {
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_complete_ad
    }

    companion object{
        fun load(context: Context, url :String =""){
            XPopup.Builder(context)
                    .hasShadowBg(true)
                    .dismissOnTouchOutside(true)
                    .popupAnimation(PopupAnimation.ScaleAlphaFromRightTop)
                    .setPopupCallback(object : SimpleCallback(){
                        override fun onShow(popupView: BasePopupView?) {
                            super.onShow(popupView)
                        }

                        override fun onDismiss(popupView: BasePopupView?) {
                            super.onDismiss(popupView)
                        }
                    })
                    .asCustom(AdTaskPopup(context, url))
                    .show()
        }
    }

    override fun onCreate() {
        super.onCreate()
        tv_btn.setOnClickListener {
            dismiss()
        }
//        im_dismiss.setOnClickListener {
//            dismiss()
//        }
    }


    override fun onDestroy() {

        super.onDestroy()
    }
}